package cn.cau.epidemicsurveysystem.service.impl;

import cn.cau.epidemicsurveysystem.bean.EpidMissionRecordBean;
import cn.cau.epidemicsurveysystem.dao.EpidMissionRecordRepository;
import cn.cau.epidemicsurveysystem.service.EpidMissionRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
@Service
public class EpidMissionRecordServiceImpl implements EpidMissionRecordService {
    @Autowired
    EpidMissionRecordRepository epidMissionRecordRepository;
    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public List<EpidMissionRecordBean> findAll(Sort sort) {
        return epidMissionRecordRepository.findAll();
    }

    @Override
    public EpidMissionRecordBean findEpidMissionRecordBeanByMissionId(int missionId) {
        return epidMissionRecordRepository.findEpidMissionRecordBeanByMissionId(missionId);
    }

    @Override
    public EpidMissionRecordBean save(EpidMissionRecordBean epidMissionRecordBean) {
        return epidMissionRecordRepository.save(epidMissionRecordBean);
    }

    @Override
    public List<EpidMissionRecordBean> findEpidMissionRecordBeansByAssigneeId(int staffId){
        return epidMissionRecordRepository.findEpidMissionRecordBeansByAssigneeIdEquals(staffId);
    }

    @Override
    public List<EpidMissionRecordBean> findEpidMissionRecordBeansByRequestHospitalOrderByRequestTime(String hospital) {
        return epidMissionRecordRepository.findEpidMissionRecordBeansByRequestHospitalOrderByRequestTime(hospital);
    }

    @Override
    public List<EpidMissionRecordBean> findEpidMissionRecordBeansBySecondAssigneeId(int secondAssigneeId){
        return epidMissionRecordRepository.findEpidMissionRecordBeansBySecondAssigneeIdEquals(secondAssigneeId);
    }

}
